package com.handinfo.android.game;

import java.io.DataInputStream;
import java.io.IOException;
import java.util.concurrent.ThreadPoolExecutor.DiscardOldestPolicy;

import android.graphics.Bitmap;

import com.handinfo.android.core.graphics.DWGraphics;
import com.handinfo.android.game.item.Item;
import com.handinfo.android.utils.Tools;

//public class TowerGameCarbon implements IIcon{
public class TowerGameCarbon {
	
	public String m_key = null;///副本的key
	//金钱
	public byte m_money_size = 0;
	public byte m_money_type[] = null;
	public long m_money[] = null;
	
	///道具
	public byte m_itemsize = 0; //道具的长度
	public Item  m_item_list[] = null; //每层的道具奖励
	
	//buff
	public byte m_buff_index = 0;///buff索引
	public Item m_buff_item=new Item();///buff道具的item
	/*
	public String m_buff_key =null;
	public String m_buff_name =null;
	public short m_buff_iconid =0;
	public Bitmap m_buff_icon =null;
	*/
	public byte m_buff_type = 0;//buff类型
	public String m_buff_description = null; //buff描述
	
	public TowerGameCarbon()
	{
	}
	/**
	 * 无数量道具
	 * @param dis
	 * @throws IOException
	 */
	public void recvItem(DataInputStream dis)throws IOException
	{
		m_itemsize = dis.readByte();
		Tools.debugPrintln("道具的长度："+m_itemsize);
		if(m_itemsize>0)
		{
			m_item_list = new Item[m_itemsize];
			for(int index =0;index<m_itemsize;index++)
			{
				Item m_item = new Item();
				m_item.m_key = dis.readUTF();
				Tools.debugPrintln("道具"+index+"的key:"+m_item.m_key);
				m_item.m_name = dis.readUTF();
				Tools.debugPrintln("道具"+index+"的name:"+m_item.m_name);
				m_item.m_iconId = (int)dis.readShort();
				Tools.debugPrintln("道具"+index+"的iconid:"+m_item.m_iconId);
			    m_item.m_icon = IconManger.getInstance().getIcon(m_item.m_iconId);
			    m_item.m_quality = dis.readByte();
			    Tools.debugPrintln("道具"+index+"的品质:"+m_item.m_quality);
				m_item_list[index] = m_item;
			}
		}
	}
//	public void drawIcon(DWGraphics g, int x, int y, int w, int h, int anchor) {
//		int icon_w = 0;
//		int icon_h = 0;
//		if( m_icon != null ){
//			icon_w = m_icon.getWidth();
//			icon_h = m_icon.getHeight();			
//			g.drawBitmap(m_icon, x, y, anchor);
//		}
//	}
//	public void drawIcon(DWGraphics g, int x, int y, int w, int h, float scaleX, float scaleY, int anchor) {
//		
//	}
	/**
	 * 金钱
	 * @param dis
	 * @throws IOException
	 */
	public void recvMoney(DataInputStream dis)throws IOException
	{
		m_money_size = dis.readByte();
		Tools.debugPrintln("金币的长度："+m_money_size);
		if(m_money_size>0)
		{
			m_money_type = new byte[m_money_size];
			m_money = new long[m_money_size];
			for(int i =0;i<m_money_size;i++)
			{
				m_money_type[i] = dis.readByte();
				Tools.debugPrintln("第"+i+"个类型："+m_money_type[i]);
				m_money[i] = dis.readLong();
				Tools.debugPrintln("第"+i+"个金币数："+m_money[i]);
			}
		}
	}
	
	/**
	 * 有数量道具
	 * @param dis
	 * @throws IOException
	 */
	public void recvItemNum(DataInputStream dis)throws IOException{
		m_itemsize = dis.readByte();
		Tools.debugPrintln("道具的长度："+m_itemsize);
		if(m_itemsize>0)
		{
			m_item_list = new Item[m_itemsize];
			for(int index =0;index<m_itemsize;index++)
			{
				Item m_item = new Item();
				m_item.m_key = dis.readUTF();
				Tools.debugPrintln("道具"+index+"的key:"+m_item.m_key);
				m_item.m_name = dis.readUTF();
				Tools.debugPrintln("道具"+index+"的name:"+m_item.m_name);
				m_item.m_iconId = (int)dis.readShort();
				Tools.debugPrintln("道具"+index+"的iconid:"+m_item.m_iconId);
			    m_item.m_icon = IconManger.getInstance().getIcon(m_item.m_iconId);
			    m_item.m_quality = (int)dis.readByte();
			    Tools.debugPrintln("道具"+index+"的品质:"+m_item.m_quality);
			    m_item.m_num = dis.readShort();
			    Tools.debugPrintln("道具"+index+"的数量:"+m_item.m_num);
				m_item_list[index] = m_item;
			}
		}
	}
}
  